import os
from core.std import Editor
from core.graph import Pipeline
from core import cmds
from core.base import ComponentSelected


from ui.delegates import AttrDelegate
from ui.widgets import QCellWidget, QContainerViewWidget, QMenuWidget, ImageWidget, DataEditorWidget
from ui.pyeditor import PythonScriptEditor
from ui.graph import GraphView
from ui.plotting import PlotGraphWidget

from PyQt4.QtCore import SIGNAL, QObject
from PyQt4.QtGui import QWidget, QCursor, QLabel, QPixmap, QHeaderView



class PlotGraph(ni.View):
    x = ni.Int()
    y = ni.Int()
    #plot = ni.Plot()
    output = ni.Component(depends=(x,y,))
    widget = PlotGraphWidget
        
    
    def compute_output(self):
        for widget in self.widgets:
            widget.plot(self.x, self.y)
        cmds.update_ui()
        return self.output
    
'''
class CellView(ni.View):
    data = ni.Tree(ni.Function(args=("parent",)))
    headers = ni.List(ni.String())
    group = ni.List(ni.Function(args=("item",)))
    relations = ni.List(ni.Function(args=("item",)))
    show_editors = ni.Bool(default=False)
    expanded = ni.Bool(default=False)
    
    widget = QCellWidget
        
    def update(self, *args):
        self.on_data_change(None)
        
    def update_widget(self, widget):
        widget._model.group_fn = self.group
        widget._model.data = self.data
        widget._model.relations = self.relations
        widget._model.headers = self.headers
        widget._model.update()
        if not self.relations:
            widget.header().hide()
        else:
            widget.header().show()
        #widget.header().setResizeMode(QHeaderView.ResizeToContents)
        
        
        
            
        if self.expanded:
            widget.expandAll()
            
        widget.resizeColumnsToContents()
        self.delegate = AttrDelegate()
        widget.setItemDelegate(self.delegate)
    
        widget.connect(widget.header(), SIGNAL("sectionResized(int,int,int)"), self.section_resized )
        
        if self.show_editors:
            widget.open_all_editors()
        
    def section_resized(self, *args, **kw):
        for widget in self.widgets:
            widget._model.emit(SIGNAL("layoutChanged()"))
'''